/**
* @author:kellen
* @contact:xiekellen@hotmail.com
* @company:achivo-gz
* @created on:
* @modified on:
*/

package com.sasis.dao.ibatis;

import java.util.List;

import com.sasis.dao.ibatis.BaseDaoiBATIS;
import com.sasis.model.VipInfo;
import com.sasis.dao.VipInfoDao;

import org.springframework.orm.ObjectRetrievalFailureException;

public class VipInfoDaoiBatis extends BaseDaoiBATIS implements VipInfoDao {

    /**
     * @see com.sasis.dao.VipInfoDao#getVipInfos(com.sasis.model.VipInfo)
     */
    public List getVipInfos(final VipInfo vipInfo) {
          return getSqlMapClientTemplate().queryForList("getVipInfos", vipInfo);
    }

    /**
     * @see com.sasis.dao.VipInfoDao#getVipInfo(Integer id)
     */
    public VipInfo getVipInfo(Integer id) {
        VipInfo vipInfo = (VipInfo) getSqlMapClientTemplate().queryForObject("getVipInfo", id);

        if (vipInfo == null) {
            throw new ObjectRetrievalFailureException(VipInfo.class, id);
        }

        return vipInfo;
    }

    /**
     * @see com.sasis.dao.VipInfoDao#saveVipInfo(VipInfo vipInfo)
     */    
    public void saveVipInfo(final VipInfo vipInfo) {
        Integer id = vipInfo.getId();
        // check for new record
        if (id == null) {
            id = (Integer) getSqlMapClientTemplate().insert("addVipInfo", vipInfo);
        } else {
            getSqlMapClientTemplate().update("updateVipInfo", vipInfo);
        }
        if( id == null ) {
            throw new ObjectRetrievalFailureException(VipInfo.class, id);
        }
    }

    /**
     * @see com.sasis.dao.VipInfoDao#removeVipInfo(Integer id)
     */
    public void removeVipInfo(VipInfo vipInfo) {
        getSqlMapClientTemplate().update("deleteVipInfo",  vipInfo);
    }

	public VipInfo getVipInfoDwr(String cardNum) {
		// TODO Auto-generated method stub
		VipInfo vipInfo = (VipInfo) getSqlMapClientTemplate().queryForObject("getVipInfoDwr", cardNum);
        return vipInfo;
	}
}
